# This file contains snippets that are always defined. I personally
# have snippets for signatures and often needed texts

# sligthly lower priority than everything else since specialized versions
# should overwrite. The user needs to adjust her priority in her snippets to
# ~-55 so that other filetypes will still overwrite.
priority -60

##############
# NICE BOXES #
##############
global !p
from vimsnippets import foldmarker, make_box, get_comment_format
endglobal

snippet box "A nice box with the current comment symbol" b
`!p
box = make_box(len(t[1]))
snip.rv = box[0]
snip += box[1]
`${1:${VISUAL:content}}`!p
box = make_box(len(t[1]))
snip.rv = box[2]
snip += box[3]`
$0
endsnippet

snippet bbox "A nice box over the full width" b
`!p
if not snip.c:
	width = int(vim.eval("&textwidth - (virtcol('.') == 1 ? 0 : virtcol('.'))")) or 71
box = make_box(len(t[1]), width)
snip.rv = box[0]
snip += box[1]
`${1:${VISUAL:content}}`!p
box = make_box(len(t[1]), width)
snip.rv = box[2]
snip += box[3]`
$0
endsnippet

snippet fold "Insert a vim fold marker" b
`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = get_comment_format()[2]`
endsnippet

snippet foldc "Insert a vim fold close marker" b
`!p snip.rv = get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = get_comment_format()[2]`
endsnippet

snippet foldp "Insert a vim fold marker pair" b
`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = get_comment_format()[2]`
${2:${VISUAL:Content}}
`!p snip.rv = get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = get_comment_format()[2]`
endsnippet

##########################
# LOREM IPSUM GENERATORS #
##########################
snippet lorem "Lorem Ipsum - 50 Words" b
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
endsnippet

##########################
# VIM MODELINE GENERATOR #
##########################
# See advice on `:help 'tabstop'` for why these values are set. Uses second
# modeline form ('set') to work in languages with comment terminators
# (/* like C */).
snippet modeline "Vim modeline"
vim`!v ':set '. (&expandtab ? printf('et sw=%i ts=%i', &sw, &ts) : printf('noet sts=%i sw=%i ts=%i', &sts, &sw, &ts)) . (&tw ? ' tw='. &tw : '') . ':'`
endsnippet

#########
# DATES #
#########
snippet date "YYYY-MM-DD" w
`!v strftime("%F")`
endsnippet

snippet ddate "Month DD, YYYY" w
`!v strftime("%b %d, %Y")`
endsnippet

snippet diso "ISO format datetime" w
`!v strftime("%F %H:%M:%S%z")`
endsnippet

snippet time "hh:mm" w
`!v strftime("%H:%M")`
endsnippet

snippet datetime "YYYY-MM-DD hh:mm" w
`!v strftime("%Y-%m-%d %H:%M")`
endsnippet

#snippet todo "TODO comment" bw
#`!p snip.rv=get_comment_format()[0]` ${2:TODO}: $0${3: <${4:`!v strftime('%y-%m-%d')`}${5:, `!v g:snips_author`}>} `!p snip.rv=get_comment_format()[2]`
#endsnippet

snippet todo "TODO comment" i
// TODO(${1:xcy}): ${2:something you can do it when you have time}
endsnippet

#=================================
#结对符
#=================================
 # 括号 bracket
snippet b "bracket" i
(${1})${2}
endsnippet
# 方括号 square bracket，设定为 st 而非 sb，避免与 b 冲突
snippet st "square bracket" i
[${1}]${2}
endsnippet
# 尖括号 angle bracket，设定为 at 而非 ab，避免与 b 冲突
snippet at "square bracket" i
<${1}>${2}
endsnippet
# 水平大括号 brace
snippet brh "brace" i
{${1}}${2}
endsnippet
# 垂直大括号 brace
snippet br "brace" i
{
	${1}
}${2}
endsnippet
# 单引号 single quote，设定为 se 而非 sq，避免与 q 冲突
snippet se "single quote" I
'${1}'${2}
endsnippet
# 双引号 quote
snippet q "quote" I
"${1}"${2}
endsnippet
# 指针符号 arrow
snippet ar "arrow" i
->${1}
endsnippet
# dot
snippet d "dot" i
.${1}
endsnippet
# 作用域 scope
snippet s "scope" i
::${1}
endsnippet
# $
snippet pp "$" i
\$${1}
endsnippet
# vim:ft=snippets:
